package com.gzz.orchid.context.application.merch.convert;

import com.gzz.orchid.context.application.merch.command.CatalogSaveCmd;
import com.gzz.orchid.context.application.merch.pojo.CatalogDto;
import com.gzz.orchid.context.application.merch.pojo.CatalogVo;
import com.gzz.orchid.context.infrastructure.definition.Status;
import com.gzz.orchid.context.infrastructure.persistence.entity.mer.MerCatalogPo;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;

/**
 * @author higmd
 */
@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE, imports = {Status.class})
public interface CatalogConverter {
    CatalogConverter INSTANCE = Mappers.getMapper(CatalogConverter.class);

    @Mappings({
            @Mapping(target = "status", expression = "java(Status.parse(po.getStatus()))"),
    })
    CatalogVo mapVo(MerCatalogPo po);

    @Mappings({
            @Mapping(target = "status", expression = "java(Status.parse(po.getStatus()))"),
    })
    CatalogDto mapDto(MerCatalogPo po);

    void updatePo(@MappingTarget MerCatalogPo po, CatalogSaveCmd cmd);
}
